package com.company.project.controller.ldjsc.robot;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.robot.ZyAiFixedProblemFieldEntity;
import com.company.project.service.ldjsc.robot.ZyAiFixedProblemFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.company.project.common.utils.DataResult;





/**
 * 智能助手固定问题对应字段
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-10-22 09:33:45
 */
@Controller
@RequestMapping("/")
public class ZyAiFixedProblemFieldController {
    @Autowired
    private ZyAiFixedProblemFieldService zyAiFixedProblemFieldService;

    /**
    * 跳转到页面
    */
    @GetMapping("/index/zyAiFixedProblemField")
    public String zyAiFixedProblemField() {
        return "zyaifixedproblemfield/list";
    }


    @ApiOperation(value = "查询分页数据")
    @PostMapping("zyAiFixedProblemField/listByPage")
    @SaCheckPermission("zyAiFixedProblemField:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody ZyAiFixedProblemFieldEntity zyAiFixedProblemField){
        LambdaQueryWrapper<ZyAiFixedProblemFieldEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        queryWrapper.eq(zyAiFixedProblemField.getId() != null, ZyAiFixedProblemFieldEntity::getId, zyAiFixedProblemField.getId());
        queryWrapper.orderByDesc(ZyAiFixedProblemFieldEntity::getId);
        IPage<ZyAiFixedProblemFieldEntity> iPage = zyAiFixedProblemFieldService.page(zyAiFixedProblemField.getQueryPage(), queryWrapper);
        return DataResult.success(iPage);
    }


    @ApiOperation(value = "新增")
    @PostMapping("zyAiFixedProblemField/add")
    @SaCheckPermission("zyAiFixedProblemField:add")
    @ResponseBody
    public DataResult add(@RequestBody ZyAiFixedProblemFieldEntity zyAiFixedProblemField){
            zyAiFixedProblemFieldService.save(zyAiFixedProblemField);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("zyAiFixedProblemField/delete")
    @SaCheckPermission("zyAiFixedProblemField:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
            zyAiFixedProblemFieldService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("zyAiFixedProblemField/update")
    @SaCheckPermission("zyAiFixedProblemField:update")
    @ResponseBody
    public DataResult update(@RequestBody ZyAiFixedProblemFieldEntity zyAiFixedProblemField){
            zyAiFixedProblemFieldService.updateById(zyAiFixedProblemField);
        return DataResult.success();
    }



}
